<!--
 * @Author: Coder_Yang
 * @description: 
 * @LastEditTime: 2025-05-07 10:00:51
-->
<template>
  <div :style="{ width: width }" v-if="!invisible">
    <el-form :label-width="labelWidth" label-position="left" :disabled="disabled">
      <el-form-item :label="name" :required="required">
        <i class="el-icon-location-outline"></i>{{ data.addr }}
      </el-form-item>
      <el-form-item label="经度" :required="required">
        <el-input placeholder="请输入经度" v-model="data.lat" clearable @input="input"></el-input>
      </el-form-item>
      <el-form-item label="纬度" :required="required">
        <el-input placeholder="请输入纬度" v-model="data.lng" clearable @input="input"></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  props: ['value', 'disabled', 'invisible', 'props', 'required', 'isBusiness'],
  data: function () {
    return {
      data: {
        lat: null,
        lng: null,
        addr: '',
        displayName: '',
      },
    }
  },
  computed: {
    myprops() {
      return this.props ? this.props : []
    },
    name() {
      let val = this.myprops.find((x) => x.FLPR_Code == 'name')
      if (val) {
        if (this.isBusiness) {
          return val.BFFP_Value ? val.BFFP_Value : '定位器'
        } else {
          return val.FFLP_Value ? val.FFLP_Value : '定位器'
        }
      }
      return '定位器'
    },
    labelWidth() {
      let val = this.myprops.find((x) => x.FLPR_Code == 'labelWidth')
      if (val) {
        if (this.isBusiness) {
          return val.BFFP_Value ? val.BFFP_Value : '140px'
        } else {
          return val.FFLP_Value ? val.FFLP_Value : '140px'
        }
      }
      return '140px'
    },
    width() {
      let val = this.myprops.find((x) => x.FLPR_Code == 'width')
      if (val) {
        if (this.isBusiness) {
          return val.BFFP_Value ? val.BFFP_Value : '100%'
        } else {
          return val.FFLP_Value ? val.FFLP_Value : '100%'
        }
      }
      return '100%'
    },
  },
  methods: {
    input() {
      this.data.displayName = this.data.addr
      this.$emit('input', JSON.stringify(this.data))
      this.$emit('display', this.data.displayName)
    },
  },
  mounted: function () {
    if (this.value) {
      this.data = JSON.parse(this.value)
      console.log(this.data);
      
    }
  },
}
</script>
<style scoped>
.el-form-item {
  margin: 10px !important;
}
</style>